# -*- coding: utf-8 -*-
# @Time    : 2023/6/5 15:25
# @Author  : hyh
# @Email   : 935887145@qq.com
# @File    : comment_page.py
# @Software: PyCharm
from pages.base_page import BasePage
from appium import webdriver
from tools import driver
from appium.webdriver.common.mobileby import MobileBy as By
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support import  expected_conditions as EC

class CommentPage(BasePage):
    picture_locator = (By.XPATH,'//*[@resource-id="com.xiachufang:id/rv_course_review"]/android.widget.FrameLayout[1]')
    pinglun_locator = (By.XPATH,'//android.widget.ImageView[@resource-id=\"com.xiachufang:id/common_control_panel_comment_btn_drawable\"]')
    input_locator = (By.XPATH,'//android.widget.EditText[@resource-id=\"com.xiachufang:id/eidt_comment_content\"]')
    send_locator = (By.XPATH,'//android.widget.TextView[@resource-id=\"com.xiachufang:id/tv_comment_publish_btn\"]')
    comment_locator =(By.XPATH,'//android.widget.TextView[@text=\"这是一条评论\"]')

    def click_picture(self):
        self.find_element(self.picture_locator).click()  #点击图片
    def click_pinlun(self):
        self.find_element(self.pinglun_locator).click()  #点击评论
    def shuru(self,input):
        self.find_element(self.input_locator).send_keys(input)  #输入内容
    def click_send(self):
        self.find_element(self.send_locator).click()  #点击发送

    def get_comment(self):
        current_comment = self.find_element(self.comment_locator).get_attribute('text')
        return current_comment